import Chart1 from "./testComponents/chart1";
import {ChartIdMap} from "../src/Charts/Charts"
import globalConfig from "./globalConfig"
import desingerCreater from "@/desinger/index"

const bodyContainer = document.getElementById("container");

const templateDesinger:boolean = true;
if(bodyContainer){
    if(templateDesinger){
        desingerCreater(bodyContainer);
    }
    !templateDesinger && globalConfig.chartStructureGroup.forEach((charts,index)=>{
        const id:string = "container"+(index+1);

        const structContainer = document.createElement("div");
        structContainer.setAttribute("id",id);
        structContainer.setAttribute("class","container");
        bodyContainer.appendChild(structContainer);

        charts.forEach(chart=>{
            const config = globalConfig.charts[chart.id];
            const component = document.createElement("div");
            component.setAttribute("id",config.container);
            component.setAttribute("class","container");
            structContainer.appendChild(component);
            const currentChart = Chart1(config);
            ChartIdMap.set(chart.id,{parent:id, self:currentChart});
            chart.active && currentChart.render();
        })
    })
}


